public class Test3 {
    public static void main(String[] args) {
        int[] nums = {55,89,84,47,76,71,75,63,18,9};
        minCostClimbingStairs(nums);
    }
    public static int minCostClimbingStairs (int[] cost) {
        // write code here
        int n = cost.length;
        if(n == 1) return cost[0];
        if(n == 2) return Math.min(cost[0], cost[1]);

        int[] dp = new int[n + 1];
        dp[1] = cost[0];
        dp[2] = cost[1];
        for(int i = 3; i <= n; i++) {
            dp[i] = Math.min(dp[i - 1] + cost[i - 2], dp[i - 2] + cost[i - 3]);
        }
        return Math.min(dp[n], dp[n - 1]);
    }
}
